﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace PLCS.EntityFrameworkCore.Migrations
{
    public partial class _032rnkadsvd : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "T_BackDatas",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Key = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Value = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ClassType = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_BackDatas", x => new { x.Id, x.Key });
                });

            migrationBuilder.CreateTable(
                name: "T_Configs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    Value = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Configs", x => new { x.Id, x.Name });
                });

            migrationBuilder.CreateTable(
                name: "T_Equipments",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    EquNum = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    SiteNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AreaNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PdLineNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EquName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    EquName_Higher = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    EquName_Lower = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Plc_Index = table.Column<int>(type: "int", nullable: false),
                    PLCAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Rack = table.Column<int>(type: "int", nullable: false),
                    Slot = table.Column<int>(type: "int", nullable: false),
                    DbNumber = table.Column<int>(type: "int", nullable: false),
                    CurrentTaskId = table.Column<int>(type: "int", nullable: false),
                    CurrentStation = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CurrentPos = table.Column<int>(type: "int", nullable: false),
                    InTrack = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    MaxPos = table.Column<int>(type: "int", nullable: false),
                    InitPos = table.Column<int>(type: "int", nullable: false),
                    CurrentSpeed = table.Column<int>(type: "int", nullable: false),
                    TrayId = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Status = table.Column<int>(type: "int", nullable: false),
                    ErrCode = table.Column<int>(type: "int", nullable: false),
                    EquType = table.Column<int>(type: "int", nullable: false),
                    ContainStationNos = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    CurrentColume = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OnlineStatus = table.Column<int>(type: "int", nullable: false),
                    IsUse = table.Column<int>(type: "int", nullable: false),
                    IsLocked = table.Column<int>(type: "int", nullable: false),
                    CompleteSignal = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Equipments", x => new { x.Id, x.EquNum });
                });

            migrationBuilder.CreateTable(
                name: "T_ErrorLibraries",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Message = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Kind = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Source = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PossibleCause = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Solution = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_ErrorLibraries", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_ErrorLogs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Message = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Kind = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Source = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDisposed = table.Column<int>(type: "int", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_ErrorLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_HisInstructions",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    InstructionNo = table.Column<int>(type: "int", nullable: false),
                    EquipmentNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    InstructionType = table.Column<int>(type: "int", nullable: false),
                    StartPos = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EndPos = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TrayType = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<int>(type: "int", nullable: false),
                    MovePos = table.Column<int>(type: "int", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_HisInstructions", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_HisOrders",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    UpperNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PdLineNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    TrayNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SolutionNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    OrderType = table.Column<int>(type: "int", nullable: false),
                    OnlineStation = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PlanStartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    PlanEndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    FactStartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    FactEndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    Status = table.Column<int>(type: "int", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_HisOrders", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_HisTasks",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    TaskId = table.Column<int>(type: "int", nullable: false),
                    TaskId_Higher = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TrayNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TaskSource = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    TaskType = table.Column<int>(type: "int", nullable: false),
                    StartPos = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    EndPos = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Level = table.Column<int>(type: "int", nullable: false),
                    TrayType = table.Column<int>(type: "int", nullable: false),
                    TaskStatus = table.Column<int>(type: "int", nullable: false),
                    BeforeExecutionMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    BeforeExecutionParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AfterExecutionMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AfterExecutionParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FinshedTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    StartTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_HisTasks", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_InstructionTimeLogs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StartPos = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    EndPos = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    RunningTime = table.Column<double>(type: "float", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_InstructionTimeLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_InterfaceLogs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RequestSide = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ResponseSide = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    InterFaceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    InterfaceDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    InterfaceMode = table.Column<int>(type: "int", nullable: false),
                    DataType = table.Column<int>(type: "int", nullable: false),
                    RequestParam = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ResponseData = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Remark = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_InterfaceLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Menus",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ViewName = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Icon = table.Column<int>(type: "int", nullable: false),
                    IsIcon = table.Column<int>(type: "int", nullable: false),
                    ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Menus", x => x.Id);
                    table.ForeignKey(
                        name: "FK_T_Menus_T_Menus_ParentId",
                        column: x => x.ParentId,
                        principalTable: "T_Menus",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "T_OrderRunningConditions",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    WhichStep = table.Column<int>(type: "int", nullable: false),
                    ProcessNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsPermit = table.Column<bool>(type: "bit", nullable: false),
                    IsEnd = table.Column<int>(type: "int", nullable: false),
                    ProcessStatus = table.Column<int>(type: "int", nullable: false),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_OrderRunningConditions", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Orders",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    UpperNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PdLineNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    TrayNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SolutionNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    OrderType = table.Column<int>(type: "int", nullable: false),
                    OnlineStation = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PlanStartTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    PlanEndTime = table.Column<DateTime>(type: "datetime2", nullable: false),
                    FactStartTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Status = table.Column<int>(type: "int", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Orders", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_PathResults",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Start = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    End = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Path = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_PathResults", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_PLCConfigs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PLCNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PLCName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IPAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Rack = table.Column<int>(type: "int", nullable: false),
                    Slot = table.Column<int>(type: "int", nullable: false),
                    DBNumber = table.Column<int>(type: "int", nullable: false),
                    Length = table.Column<int>(type: "int", nullable: false),
                    Type = table.Column<int>(type: "int", nullable: false),
                    IsUse = table.Column<int>(type: "int", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_PLCConfigs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Processes",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ProcessNo = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    ProcessName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    TargetPos = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ContinueProcess = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsTrigger = table.Column<bool>(type: "bit", nullable: false),
                    IsEnd = table.Column<int>(type: "int", nullable: false),
                    TriggerStrings = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    WorkStepStrings = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    BeforeExecutionMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    BeforeExecutionParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AfterExecutionMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AfterExecutionParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Processes", x => new { x.Id, x.ProcessNo });
                });

            migrationBuilder.CreateTable(
                name: "T_Roles",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RoleName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    MenusString = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Roles", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_RunningLogs",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    ActionType = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Kind = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    User = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    View = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_RunningLogs", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Solutions",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SolutionNo = table.Column<string>(type: "nvarchar(450)", nullable: false),
                    SolutionName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    SolutionStepStrings = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Solutions", x => new { x.Id, x.SolutionNo });
                });

            migrationBuilder.CreateTable(
                name: "T_SolutionSteps",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StepNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    StepOrder = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Process = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    FinalProcess = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_SolutionSteps", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Stations",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SiteNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AreaNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PdLineNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    StaName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    StaName_Higher = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    StaName_Lower = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    StaNum = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    StationType = table.Column<int>(type: "int", nullable: false),
                    Capacity = table.Column<int>(type: "int", nullable: false),
                    MultipleTrayType = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    MultipleMaterialSize = table.Column<int>(type: "int", nullable: false),
                    CurrentTrayType = table.Column<int>(type: "int", nullable: false),
                    CurrentMaterialSize = table.Column<int>(type: "int", nullable: false),
                    TrayCount = table.Column<int>(type: "int", nullable: false),
                    CanOutStatusJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CanInSideStatusJson = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CanSend = table.Column<bool>(type: "bit", nullable: false),
                    CanGet = table.Column<bool>(type: "bit", nullable: false),
                    HaveStatus = table.Column<int>(type: "int", nullable: false),
                    Kind = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    Level = table.Column<int>(type: "int", nullable: false),
                    LastEnterDate = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Completion_Signal = table.Column<int>(type: "int", nullable: false),
                    CacheStation = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Weight = table.Column<int>(type: "int", nullable: false),
                    ErrCode = table.Column<int>(type: "int", nullable: false),
                    Position = table.Column<int>(type: "int", nullable: false),
                    IsLocked = table.Column<int>(type: "int", nullable: false),
                    CanTake_EquNum = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CanSend_EquNum = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    IsUse = table.Column<int>(type: "int", nullable: false),
                    IsBeUsed = table.Column<bool>(type: "bit", nullable: false),
                    FullChangedMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    FullChangedParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EmptyChangedMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EmptyChangedParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Stations", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Tasks",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    TaskId = table.Column<int>(type: "int", nullable: false),
                    TaskId_Higher = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    OrderNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TrayNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TaskSource = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    TaskType = table.Column<int>(type: "int", nullable: false),
                    StartPos = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EndPos = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Level = table.Column<int>(type: "int", nullable: false),
                    WayStation = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TrayType = table.Column<int>(type: "int", nullable: false),
                    TaskStatus = table.Column<int>(type: "int", nullable: false),
                    BeforeExecutionMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    BeforeExecutionParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AfterExecutionMethod = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AfterExecutionParam = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    StartTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Tasks", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Triggers",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    BackDataKey = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    BackDataPath = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ComparisonType = table.Column<int>(type: "int", nullable: false),
                    CompareValue = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Triggers", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_Users",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    UserName = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    RolesString = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PassWord = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Users", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "T_PLCReadDatas",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    PLCReadDataNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    PLCConfigId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    StartBit = table.Column<int>(type: "int", nullable: false),
                    EndBit = table.Column<int>(type: "int", nullable: false),
                    CurrentValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    HistoricalValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    DataType = table.Column<int>(type: "int", nullable: false),
                    Length = table.Column<int>(type: "int", nullable: false),
                    Remarks = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    IsDependency = table.Column<int>(type: "int", nullable: false),
                    CorrespondingField = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CorrespondingTable = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    CorrespondingType = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    WhereField = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    WhereValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_PLCReadDatas", x => x.Id);
                    table.ForeignKey(
                        name: "FK_T_PLCReadDatas_T_PLCConfigs_PLCConfigId",
                        column: x => x.PLCConfigId,
                        principalTable: "T_PLCConfigs",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "T_Trays",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    SiteNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    AreaNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    PdLineNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TrayNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    StationId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    TrayType = table.Column<int>(type: "int", nullable: false),
                    TrayStatus = table.Column<int>(type: "int", nullable: false),
                    MaterialSize = table.Column<int>(type: "int", nullable: false),
                    HaveStatus = table.Column<int>(type: "int", nullable: false),
                    MaterialNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EnterTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Trays", x => x.Id);
                    table.ForeignKey(
                        name: "FK_T_Trays_T_Stations_StationId",
                        column: x => x.StationId,
                        principalTable: "T_Stations",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateTable(
                name: "T_Instructions",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    InstructionNo = table.Column<int>(type: "int", nullable: false),
                    TaskId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    EquipmentNo = table.Column<string>(type: "nvarchar(max)", nullable: false),
                    ContainStationNo = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    InstructionType = table.Column<int>(type: "int", nullable: false),
                    InitalPos = table.Column<int>(type: "int", nullable: false),
                    MovePos = table.Column<int>(type: "int", nullable: false),
                    StartPos = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    EndPos = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    TrayType = table.Column<int>(type: "int", nullable: false),
                    Status = table.Column<int>(type: "int", nullable: false),
                    UnexecutedReason = table.Column<string>(type: "nvarchar(max)", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_T_Instructions", x => x.Id);
                    table.ForeignKey(
                        name: "FK_T_Instructions_T_Tasks_TaskId",
                        column: x => x.TaskId,
                        principalTable: "T_Tasks",
                        principalColumn: "Id");
                });

            migrationBuilder.CreateIndex(
                name: "IX_T_Instructions_TaskId",
                table: "T_Instructions",
                column: "TaskId");

            migrationBuilder.CreateIndex(
                name: "IX_T_Menus_ParentId",
                table: "T_Menus",
                column: "ParentId");

            migrationBuilder.CreateIndex(
                name: "IX_T_PLCReadDatas_PLCConfigId",
                table: "T_PLCReadDatas",
                column: "PLCConfigId");

            migrationBuilder.CreateIndex(
                name: "IX_T_Trays_StationId",
                table: "T_Trays",
                column: "StationId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "T_BackDatas");

            migrationBuilder.DropTable(
                name: "T_Configs");

            migrationBuilder.DropTable(
                name: "T_Equipments");

            migrationBuilder.DropTable(
                name: "T_ErrorLibraries");

            migrationBuilder.DropTable(
                name: "T_ErrorLogs");

            migrationBuilder.DropTable(
                name: "T_HisInstructions");

            migrationBuilder.DropTable(
                name: "T_HisOrders");

            migrationBuilder.DropTable(
                name: "T_HisTasks");

            migrationBuilder.DropTable(
                name: "T_Instructions");

            migrationBuilder.DropTable(
                name: "T_InstructionTimeLogs");

            migrationBuilder.DropTable(
                name: "T_InterfaceLogs");

            migrationBuilder.DropTable(
                name: "T_Menus");

            migrationBuilder.DropTable(
                name: "T_OrderRunningConditions");

            migrationBuilder.DropTable(
                name: "T_Orders");

            migrationBuilder.DropTable(
                name: "T_PathResults");

            migrationBuilder.DropTable(
                name: "T_PLCReadDatas");

            migrationBuilder.DropTable(
                name: "T_Processes");

            migrationBuilder.DropTable(
                name: "T_Roles");

            migrationBuilder.DropTable(
                name: "T_RunningLogs");

            migrationBuilder.DropTable(
                name: "T_Solutions");

            migrationBuilder.DropTable(
                name: "T_SolutionSteps");

            migrationBuilder.DropTable(
                name: "T_Trays");

            migrationBuilder.DropTable(
                name: "T_Triggers");

            migrationBuilder.DropTable(
                name: "T_Users");

            migrationBuilder.DropTable(
                name: "T_Tasks");

            migrationBuilder.DropTable(
                name: "T_PLCConfigs");

            migrationBuilder.DropTable(
                name: "T_Stations");
        }
    }
}
